import java.util.InputMismatchException;

public class MyMenu {
    public static int selectMenu(String[] choices){
        int result;
        while (true){
            try {
                for(String choice:choices) System.out.println(choice);
                result= GoldfishReader.scanner.nextInt();
                if(result>=0&&result<choices.length) {
                    return result;
                }
                System.out.println("Please Enter a number between 0-"
                        +(choices.length-1)
                );
            }
            catch (InputMismatchException inputMismatchException){
                System.out.println();
            }
            finally {
                GoldfishReader.scanner.nextLine();
            }
        }
    }
}
